package com.tfjybj.itoo.exam.provider.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tfjybj.itoo.exam.entity.PaperRecordEntity;
import com.tfjybj.itoo.exam.entity.TemplateDetailsEntity;
import com.tfjybj.itoo.exam.model.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * PaperRecordDao接口
 * paperRecord表
 *
 * @author 任晓帅
 * @version 2.0.0
 * @since 2.0.0 2018-11-15 19:40:28
 */
@Repository("paperRecordDao")
public interface PaperRecordDao extends BaseMapper<PaperRecordEntity> {

    //region 模板生成：模糊查询

    /**
     * 根据考生_id模糊查询paperRecord
     *
     * @param examineeId 考生_id
     * @return 模糊查询的paperRecord集合
     * @author 任晓帅
     * @since 2.0.0 2018-11-15 19:40:28
     */
    List<PaperRecordEntity> queryLikeExamineeId(@Param("examineeId") String examineeId);
    //endregion

    /* **********************************以下为非模板生成的内容********************************* */


//    /**
//     * 查询试卷详情--樊建华--2018年11月22日21:03:37
//     *
//     * @param paperId 试卷id
//     * @return 试卷详情
//     */
//    ExamPaperModel selectPaperInfoByPaperRecord(@Param("paperId") String paperId);

    /**
     * 根据模版_id 查询试卷详细信息
     *
     * @param templateId 模版_id
     * @return 试卷详细信息的ExamPaperModel
     * @author 杨楠
     * @since 2.0.0 2018-11-23 19:40:28
     */


    ExamPaperModel selectPaperInfoByPaperRecord(String templateId);

    /**
     * 根据模版_id 查询题干详情信息
     *
     * @param templateId 模版_id
     * @param examineeId 考生_id
     * @return 题干详情信息QuestionMainModel
     * @author 杨楠
     * @since 2.0.0 2018-11-23 19:40:28
     */
    List<QuestionMainModel> selectMainInfoByPaperRecord(@Param("templateId") String templateId, @Param("examineeId") String examineeId);

    /**
     * 查询所有子题的答题记录信息
     * @param templateId
     * @param examineeId
     * @return
     * @Author 李娜
     */
    List<QuestionMainModel> selectQuestionByChildId(@Param("templateId") String templateId, @Param("examineeId") String examineeId);

    List<TemplateDetailsEntity> selectQuestionTypeByExamineeId(@Param("examineeId") String examineeId);
    /**
     * 根据学生id和试卷id查询小题详情
     *
     * @return 返回根据学生id和试卷id查出小题的详情
     * @author maying
     * @since 2018-11-27 08:10:38
     */
    List<PaperRecordEntity> selStuDetails(@Param("examineeId") String examineeId, @Param("templateId") String templateId);

    /**
     * 插入答题记录
     *
     * @param recordEntityList 试卷记录实体集合
     * @return 判断是否成功标识
     * @author 杨楠
     * @since 2.0.0 2018-11-23 19:40:28
     */
    int insertAllPaperRecord(@Param("recordEntityList") List<PaperRecordEntity> recordEntityList, @Param("examineeId") String examineeId, @Param("examinationId") String examinationId);

    /**
     * 查询学生答案
     *
     * @param examineeId 考考生id
     * @param templateId 试卷记录实体集合
     * @param courseId   课程id
     * @return 判断是否成功标识
     * @author 王雪芬
     * @since 2.0.0 2018-11-23 19:40:28
     */
    List<PaperRecordModel> queryRecordStudentAnswer(@Param("examineeId") String examineeId, @Param("templateId") String templateId, @Param("courseId") String courseId);

    /**
     * 查正在考试抽到错题的考生
     *
     * @param wrongQuestionId 题的Id
     * @return 抽到错题的考生集合
     * @author 任蒙蒙
     * @since 2.0.0 2018-12-17 19:10:28
     */
    List<ExamineeModel> selectExamineeByQuestionId(@Param("wrongQuestionId") String wrongQuestionId);

    /**
     * 查询每个抽到错题的考生答题记录主键id
     *
     * @param examineeId      答题记录的Id
     * @param templateId      新题的id
     * @param wrongQuestionId 答题记录的Id
     * @author 任蒙蒙
     * @since 2.0.0 2018-11-17 17:10:28
     */
    PaperRecordEntity selectPaperRecordId(@Param("examineeId") String examineeId, @Param("templateId") String templateId, @Param("wrongQuestionId") String wrongQuestionId);


    List<String> queryPaperRecordId(@Param("examineeId") String examineeId, @Param("examinationId") String examinationId);

    /**
     * 查询考试所有试题的正确率
     *
     * @param examID 考试ID
     * @return
     * @author 魏恩君
     * @since 2.0.0 2019/1/26
     */

    List<PaperRecordModel> queryQuestionCorrectRate(@Param("examID") String examID);

    StudentScoreLittlePracticeModel selectPaperRecordByexaminee(@Param("examineeId") String examineeId);

    //改交卷状态汇总成绩
    ExamineeTotalScoreModel selectExameeScoreSum(@Param("examineeId") String examineeId, @Param("examinationId") String examinationId);

    //不改交卷状态汇总成绩-谷海涛
    ExamineeTotalScoreModel selectExameeScoreSumPra(@Param("examineeId") String examineeId, @Param("examinationId") String examinationId);

    List<PaperRecordEntity> selectExameeAnswerRight(@Param("examineeId") String examineeId, @Param("examinationId") String examinationId);
    //不改交卷状态查正确答案-谷海涛
    List<PaperRecordEntity> selectExameeAnswerRightPra(@Param("examineeId") String examineeId, @Param("examinationId") String examinationId);


    /**
     * 课程练习-保存学生答题记录
     *
     * @param coursePaperRecordModel
     * @return 是否插入成功
     * @author 贾建清
     * @since 2.0.0 2019-3-26 15:48:15
     */
    List<PaperRecordEntity> insertPaperRecord(@Param("coursePaperRecordModel") CoursePaperRecordModel coursePaperRecordModel);


    /**
     * 课程练习-根据用户id查询该用户做题记录
     *
     * @param examineeId
     * @return 是否查询成功
     * @ahthor 贾建清
     * @since 2.0.0 2019-3-27 09:05:19
     */
    List<CoursePaperRecordModel> queryQuestionStudentAnswer(@Param("examineeId") String examineeId);


    /**
     * 课程练习-根据用户id和题干id更新用户答案
     *
     * @param examineeId
     * @param questionId
     * @param coursePaperRecordModel
     * @return 是否更新成功
     * @anthor 贾建清
     * @since 2.0.0 2019-3-27 10:58:24
     */
    boolean updateStudentAnswer(@Param("examineeId") String examineeId, @Param("questionId") String questionId, @Param("coursePaperRecordModel") CoursePaperRecordModel coursePaperRecordModel);

}
